#coding:UTF-8
from tkinter import *
import webbrowser


root=Tk()

text1=Text(root,width=30,height=5)
text1.pack()

text1.insert(INSERT,'学习代码技术的天堂：哔哩哔哩')
text1.tag_add("link","1.10",'1.14')
text1.tag_config("link",foreground="red",underline=True)

def show_arrow_cursor(event):
    text1.config(cursor="arrow")

def show_xterm_cursor(event):
    text1.config(cursor="xterm")

def click(event):
    webbrowser.open("https://www.bilibili.com")

#鼠标进入文本时候进入“arrow”形态。离开后切换为“xterm”形态
text1.tag_bind("link","<Enter>",show_arrow_cursor)
text1.tag_bind("link","<Leave>",show_xterm_cursor)
text1.tag_bind("link","<Button-1>",click)

mainloop()